package com.rskj.cashbook.vo;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 自动记账规则执行记录实体类
 * @author system
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class AutoAccountingExecutionLog extends BaseEntity {
    
    /**
     * 规则ID
     */
    private String ruleId;
    
    /**
     * 规则名称
     */
    private String ruleName;
    
    /**
     * 执行时间
     */
    private LocalDateTime executeTime;
    
    /**
     * 执行结果：SUCCESS(成功)、FAILED(失败)、SKIPPED(跳过)
     */
    private String executeResult;
    
    /**
     * 实际记账金额
     */
    private BigDecimal amount;
    
    /**
     * 生成的记账记录ID
     */
    private String cashBookId;
    
    /**
     * 错误信息
     */
    private String errorMessage;
    
    /**
     * 执行耗时(毫秒)
     */
    private Long executionDuration;
    
    /**
     * 执行结果描述
     */
    public String getExecuteResultDescription() {
        if (executeResult == null) return "";
        
        switch (executeResult) {
            case "SUCCESS":
                return "成功";
            case "FAILED":
                return "失败";
            case "SKIPPED":
                return "跳过";
            default:
                return executeResult;
        }
    }
    
    /**
     * 执行结果颜色
     */
    public String getExecuteResultColor() {
        if (executeResult == null) return "default";
        
        switch (executeResult) {
            case "SUCCESS":
                return "success";
            case "FAILED":
                return "error";
            case "SKIPPED":
                return "warning";
            default:
                return "default";
        }
    }
}
